package com.aaa.sbm.service.impl;

import com.aaa.sbm.dao.RoleDao;
import com.aaa.sbm.entity.Role;
import com.aaa.sbm.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    
    @Autowired
    private RoleDao roleDao;

    @Override
    public List<Role> selectRoleList() {
        return roleDao.selectRoleList();
    }

    @Override
    public List<Role> selectRolesByUserId(Long userId) {
        return roleDao.selectRolesByUserId(userId);
    }

    @Override
    @Transactional
    public int insertUserRole(Long userId, Long[] roleIds) {
        if (roleIds == null || roleIds.length == 0) {
            return 0;
        }
        return roleDao.insertUserRole(userId, roleIds);
    }

    @Override
    @Transactional
    public int deleteUserRoleByUserId(Long userId) {
        return roleDao.deleteUserRoleByUserId(userId);
    }
} 